package cp.remote.activity;

import cp.remote.R;
import cp.remote.config.KinectConfig;
import cp.remote.controller.StopTask;
import cp.remote.timer.KinectTimer;
import android.os.Bundle;
import android.os.Handler;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;

public class PeopleTracking_Activity extends Main_Activity {

    private KinectTimer t = null;
    private EditText state;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.people_tracking);
        
        state = (EditText) findViewById(R.id.people_txt_state);

        if (KinectConfig.kinectimage) {
            state.append("Task Run with Kinectimage\n");
            Handler myHandler = new Handler();
            t = new KinectTimer(myHandler,
                    (ImageView) findViewById(R.id.people_video));
            myHandler.removeCallbacks(t);
            myHandler.postDelayed(t, 100);
        }else{
            state.append("Task Run without Kinectimage\n");            
        }
    }
    
    @Override
    public void onStart(){
        super.onStart();
        ((ImageButton) findViewById(R.id.people_button_stop))
        .setOnClickListener(new StopTask(this));
    }
    
    @Override
    public void customStop() {
        if (t != null)
            t.stop();
    }

    @Override
    public void setStateText(String text) {
        state.append(text + "\n");        
    }
}
